<template>
	<view class="minecenter" :style="{height: mineHeight+'px'}">
		<view class="box d-ai-c d-jc-sb" :class="userInfo.userInfo.userAccompanyInfo.identity==1?'bg':'card'" >
			<view class="cardleft">
				<view class="identifylabel box d-ai-c">
					<view class="" @tap="login" v-if="!loginState">
						立即登录/注册
					</view>
					<view class="" v-if="loginState">
						{{userInfo.userInfo.userAccompanyInfo.name==undefined?userInfo.userInfo.tuser.nickName:userInfo.userInfo.userAccompanyInfo.name}}
					</view>
					<view class="ml-1" v-if="loginState&&userInfo.userInfo.userAccompanyInfo.identity==0">
						陪诊员
					</view>
					<view class="ml-1" v-if="loginState&&userInfo.userInfo.userAccompanyInfo.identity==1">
						高级陪诊员
					</view>
				</view>
				<view class="worknum" v-if="loginState">
					工号:{{userInfo.userInfo.userAccompanyInfo.accompanyId==null?0:userInfo.userInfo.userAccompanyInfo.accompanyId}}
				</view>
				<view class="box mt-3 d-jc-sb">
					<view class="boxlist">
						<view class="" style="color: #4CA6FF;" v-if="loginState">
							{{userInfo.userInfo.serviceCont==null?0:userInfo.userInfo.serviceCont}}
						</view>
						<view class="" style="color: #4CA6FF;" v-if="!loginState">
							{{userInfo.userInfo.serviceCont==undefined?0:userInfo.userInfo.serviceCont}}
						</view>
						<view class="">
							服务次数
						</view>
					</view>
					<view class="boxlist">
						<view class="" style="color: #55C47D ;" v-if="loginState">
							{{userInfo.userInfo.monthCount==null?0:userInfo.userInfo.monthCount}}
						</view>
						<view class="" style="color: #55C47D ;" v-if="!loginState">
							{{userInfo.userInfo.monthCount==undefined?0:userInfo.userInfo.monthCount}}
						</view>
						<view class="">
							本月接单
						</view>
					</view>
					<view class="boxlist">
						<view class="" style="color: #FF8833;" v-if="loginState">
							{{userInfo.userInfo.accompanyWalletRecode==null?0:userInfo.userInfo.accompanyWalletRecode}}
						</view>
						<view class="" style="color: #FF8833;" v-if="!loginState">
							{{userInfo.userInfo.accompanyWalletRecode==undefined?0:userInfo.userInfo.accompanyWalletRecode}}
						</view>
						<view class="">
							订单收入
							
						</view>
					</view>
				</view>
			</view>
			<view class="cardright">
				<image v-if="!loginState" src="https://xb-street.oss-cn-shanghai.aliyuncs.com/xb-doctor-manage/static/images/touxiang@2x.png" mode=""></image>
				<image v-if="loginState" :src="userInfo.userInfo.userAccompanyInfo.image==undefined?userInfo.userInfo.tuser.image:userInfo.userInfo.userAccompanyInfo.image" mode=""></image>
			</view>
		</view>
		<view class="wallet box d-ai-c d-jc-sb">
			<view class="walletleft box d-ai-c">
				<image src="https://xb-street.oss-cn-shanghai.aliyuncs.com/xb-doctor-manage/static/images/qianbao@2x.png" mode=""></image>
				<view class="ml-1" v-if="loginState">
					￥{{userInfo.userInfo.money==null?0:userInfo.userInfo.money}}
				</view>
				<view class="ml-1" v-if="!loginState">
					￥0
				</view>
			</view>
			<view class="walletright box d-ai-c" @tap="openwalletInfo">
				<view class="">
					钱包详情
				</view>
				<image src="https://xb-street.oss-cn-shanghai.aliyuncs.com/xb-doctor-manage/static/images/tiaozhuan.png" mode=""></image>
			</view>
		</view>
		<view class="cbot box d-jc-sb d-f-wrap">
			<view class="botlist" @tap="openorder">
				<image src="https://xb-street.oss-cn-shanghai.aliyuncs.com/xb-doctor-manage/static/images/wddd@2x.png" mode=""></image>
				<view class="mt-1">
					我的订单
				</view>
			</view>
			<view class="botlist" @tap="openevaluate">
				<image src="https://xb-street.oss-cn-shanghai.aliyuncs.com/xb-doctor-manage/static/images/yhpj@2x.png" mode=""></image>
				<view class="mt-1">
					用户评价
				</view>
			</view>
			<view class="botlist" @tap="openrecommend">
				<image src="https://xb-street.oss-cn-shanghai.aliyuncs.com/xb-doctor-manage/static/images/tjpy@2x.png" mode=""></image>
				<view class="mt-1">
					推荐朋友
				</view>
			</view>
		</view>
		<view class="cbot box d-f-wrap">
			<view class="botlist" @tap="openauth">
				<image src="https://xb-street.oss-cn-shanghai.aliyuncs.com/xb-doctor-manage/static/images/pzyrz@2x.png" mode=""></image>
				<view class="mt-1">
					陪诊员认证
				</view>
				<view class="" v-if="userInfo.userInfo.tuser!=null"> 
					未认证
				</view>
				<view class="" v-if="userInfo.userInfo.tuser==null && userInfo.userInfo.userAccompanyInfo.status==1">
					审核中
				</view>
				<view class="" v-if="userInfo.userInfo.tuser==null && userInfo.userInfo.userAccompanyInfo.status==0">
					已认证
				</view>
			</view>
			<view class="botlist ml-2" @tap="openset">
				<image src="../../static/sz@2x.png" mode=""></image>
				<view class="mt-1">
					账户设置
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default {
		data() {
			return {
				mineHeight:400,
			}
		},
		onReady() {
			let that = this;
			uni.getSystemInfo({ //调用uni-app接口获取屏幕高度
				success(res) { //成功回调函数
					that.mineHeight = res.windowHeight - uni.upx2px(0) //windoHeight为窗口高度，主要使用的是这个
				}
			})
		},
		onShow() {
					if(this.loginState){
						this.getUserInfo()
					}
				},
		computed: mapState(['loginState', 'userInfo']),
		methods: {
			openset(){
				uni.navigateTo({
					url:'setting'
				})
			},
			...mapMutations(['login', 'logout','setUserInfo']),
			// 获取用户信息
			getUserInfo() {
				this.$api.getUserInfo().then((res) => {
					let userInfo = res.data.dataMap
					// this.getUserIn = res.data.dataMap
					console.log(userInfo)
					if (userInfo != null) {
						this.setUserInfo(userInfo)
					}
			
				})
			
			},
			openwalletInfo(){
				if(this.loginState){
					if(this.userInfo.userInfo.accompanyWalletRecode==null){
						uni.showToast({
							title:'请前往认证成为陪诊',
							icon:'none',
						})
						uni.navigateTo({
							url:'../index/authentication'
						})
					}else{
						uni.navigateTo({
							url:'walletInfo'
						})
					}
				}else{
					uni.navigateTo({
						url:'author'
					})
				}
				
			},
			login(){
				uni.navigateTo({
					url:'author'
				})
			},
			openauth(){
				if(this.loginState){
					if(this.userInfo.userInfo.tuser!=null){
						uni.navigateTo({
							url:'../index/authentication'
						})
						
						
					}else { //1 //审核中 2审核失败 0成功
					if(this.userInfo.userInfo.userAccompanyInfo.status==1){
						uni.showToast({
							title:'审核中',
							icon:'none',
						})
					}else if(this.userInfo.userInfo.userAccompanyInfo.status==2){
						uni.navigateTo({
							url:'../index/authentication'
						})
					}else if(this.userInfo.userInfo.userAccompanyInfo.status==0){
						uni.showToast({
							title:'已完成认证',
							icon:'none',
						})
					}
						// uni.showToast({
						// 	title:'已完成认证',
						// 	icon:'none',
						// })
					}
					
				}else{
					uni.navigateTo({
						url:'author'
					})
				}
				
			},
			openorder(){
				if(this.loginState){
					if(this.userInfo.userInfo.accompanyWalletRecode==null){
						uni.showToast({
							title:'请前往认证成为陪诊',
							icon:'none',
						})
					}else{
						uni.navigateTo({
							url:'myorder'
						})
					}
				}else{
					uni.navigateTo({
						url:'author'
					})
				}
				
				
			},
			openevaluate(){
				if(this.loginState){
					if(this.userInfo.userInfo.accompanyWalletRecode==null){
						uni.showToast({
							title:'请前往认证成为陪诊',
							icon:'none',
						})
					}else{
						uni.navigateTo({
							url:'evaluation'
						})
					}
				}else{
					uni.navigateTo({
						url:'author'
					})
				}
				
				
			},
			openrecommend(){
				if(this.loginState){
					if(this.userInfo.userInfo.accompanyWalletRecode==null){
						uni.showToast({
							title:'请前往认证成为陪诊',
							icon:'none',
						})
					}else{
						uni.navigateTo({
							url:'Recommend'
						})
					}
				}else{
					uni.navigateTo({
						url:'author'
					})
				}
			},
		}
	}
</script>

<style scoped lang="less">
	
.minecenter{
	background: #F2F7FF;
	overflow: hidden;
}
.bg{
	width: 690rpx;
	height: 240rpx;
	padding: 30rpx 0 ;
	background: url('https://xb-street.oss-cn-shanghai.aliyuncs.com/xb-doctor-manage/static/kp@2x.png') no-repeat;
	background-size: cover;
	// border-radius: 12rpx;
	margin: 0 auto;
	margin-top: 32rpx;
	.cardleft{
		width: 500rpx;
		// border:1rpx solid red;
		.identifylabel{
			padding-left: 30rpx;
			view:nth-child(1){
				font-size: 40rpx;
				font-weight: bold;
				color: #FFE0BE;
			}
			view:nth-child(2){
				width: 160rpx;
				height: 36rpx;
				background: #FFE0BE;
				border-radius: 18rpx;
				font-size: 24rpx;
				font-weight: 500;
				color: #FF8833;
				line-height: 36rpx;
				text-align: center;
			}
		}
		.worknum{
			padding-left: 30rpx;
			margin-top: 20rpx;
			font-size: 26rpx;
			font-weight: 500;
			color: #FFE0BE;
		}
		.boxlist{
			width: 160rpx;
			height: 120rpx;
			text-align: center;
			view:nth-child(1){
				font-size: 32rpx;
				font-weight: bold;
			}
			view:nth-child(2){
				margin-top: 15rpx;
				font-size: 26rpx;
				font-weight: 500;
				color: #999999;
			}
		}
	}
	.cardright{
		padding-right: 30rpx;
		image{
			width: 120rpx;
			height: 120rpx;
		}
	}
}
.card{
	width: 690rpx;
	height: 240rpx;
	padding: 30rpx 0 ;
	background: #FFFFFF;
	border-radius: 12rpx;
	margin: 0 auto;
	margin-top: 32rpx;
	.cardleft{
		width: 500rpx;
		// border:1rpx solid red;
		.identifylabel{
			padding-left: 30rpx;
			view:nth-child(1){
				font-size: 40rpx;
				font-weight: bold;
				color: #333333;
			}
			view:nth-child(2){
				width: 120rpx;
				height: 36rpx;
				background: #4CA6FF;
				border-radius: 18rpx;
				font-size: 24rpx;
				font-weight: 500;
				color: #FFFFFF;
				line-height: 36rpx;
				text-align: center;
			}
		}
		.worknum{
			padding-left: 30rpx;
			margin-top: 20rpx;
			font-size: 26rpx;
			font-weight: 500;
			color: #999999;
		}
		.boxlist{
			width: 160rpx;
			height: 120rpx;
			text-align: center;
			view:nth-child(1){
				font-size: 32rpx;
				font-weight: bold;
			}
			view:nth-child(2){
				margin-top: 15rpx;
				font-size: 26rpx;
				font-weight: 500;
				color: #999999;
			}
		}
	}
	.cardright{
		padding-right: 30rpx;
		image{
			width: 120rpx;
			height: 120rpx;
		}
	}
}
.wallet{
	width: 630rpx;
	height: 120rpx;
	padding: 0 30rpx;
	background: linear-gradient(89deg, #FAB650 0%, #FFD166 100%);
	border-radius: 12rpx;
	margin: 0 auto;
	margin-top: 30rpx;
	.walletleft{
		image{
			width: 54rpx;
			height: 54rpx;
		}
		view{
			font-size: 40rpx;
			font-weight: bold;
			color: #512B0A;
		}
	}
	.walletright{
		image{
			width: 30rpx;
			height: 28rpx;
		}
		view{
			font-size: 28rpx;
			font-weight: 500;
			color: #512B0A;
		}
	}
}
.cbot{
	width: 690rpx;
	margin: 0 auto;
	margin-top: 30rpx;
	// border:1px solid red;
	.botlist{
		width: 214rpx;
		min-height: 185rpx;
		background: #FFFFFF;
		border-radius: 12rpx;
		text-align: center;
		padding-bottom: 30rpx;
		image{
			margin-top: 30rpx;
			width: 80rpx;
			height: 80rpx;
		}
		view:nth-child(2){
			font-size: 28rpx;
			font-weight: 500;
			color: #333333;
		}
		view:nth-child(3){
			font-size: 24rpx;
			font-weight: 500;
			color: #FA3232;
		}
	}
}
</style>
